package com.ruoyi.Warehouse.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.Warehouse.domain.Cardsets;
import com.ruoyi.Warehouse.service.ICardsetsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 卡牌系列表Controller
 * 
 * @author ruoyi
 * @date 2025-06-16
 */
@Controller
@RequestMapping("/pims/cardsets")
public class CardsetsController extends BaseController
{
    private String prefix = "pims/cardsets";

    @Autowired
    private ICardsetsService cardsetsService;

    @RequiresPermissions("pims:cardsets:view")
    @GetMapping()
    public String cardsets()
    {
        return prefix + "/cardsets";
    }

    /**
     * 查询卡牌系列表列表
     */
    @RequiresPermissions("pims:cardsets:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Cardsets cardsets)
    {
        startPage();
        List<Cardsets> list = cardsetsService.selectCardsetsList(cardsets);
        return getDataTable(list);
    }

    /**
     * 导出卡牌系列表列表
     */
    @RequiresPermissions("pims:cardsets:export")
    @Log(title = "卡牌系列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Cardsets cardsets)
    {
        List<Cardsets> list = cardsetsService.selectCardsetsList(cardsets);
        ExcelUtil<Cardsets> util = new ExcelUtil<Cardsets>(Cardsets.class);
        return util.exportExcel(list, "卡牌系列表数据");
    }

    /**
     * 新增卡牌系列表
     */
    @RequiresPermissions("pims:cardsets:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存卡牌系列表
     */
    @RequiresPermissions("pims:cardsets:add")
    @Log(title = "卡牌系列表", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Cardsets cardsets)
    {
        return toAjax(cardsetsService.insertCardsets(cardsets));
    }

    /**
     * 修改卡牌系列表
     */
    @RequiresPermissions("pims:cardsets:edit")
    @GetMapping("/edit/{setId}")
    public String edit(@PathVariable("setId") Long setId, ModelMap mmap)
    {
        Cardsets cardsets = cardsetsService.selectCardsetsBySetId(setId);
        mmap.put("cardsets", cardsets);
        return prefix + "/edit";
    }

    /**
     * 修改保存卡牌系列表
     */
    @RequiresPermissions("pims:cardsets:edit")
    @Log(title = "卡牌系列表", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Cardsets cardsets)
    {
        return toAjax(cardsetsService.updateCardsets(cardsets));
    }

    /**
     * 删除卡牌系列表
     */
    @RequiresPermissions("pims:cardsets:remove")
    @Log(title = "卡牌系列表", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(cardsetsService.deleteCardsetsBySetIds(ids));
    }
}
